package com.djakapm.swing.component.textarea;

import org.junit.Test;

import java.awt.*;

import static org.junit.Assert.assertTrue;

public class SpecForTextAreaView {


    @Test
    public void can_hide_line_number_as_default(){
        TextAreaView textAreaView = new TextAreaView();
        assertTrue("Line number panel should be hidden by default",!textAreaView.getLineNumberPanel().isVisible());
    }

    @Test
    public void can_show_line_number(){
        TextAreaView textAreaView = new TextAreaView();
        textAreaView.setShowLineNumber(true);
        assertTrue("Line number panel should be shown",textAreaView.getLineNumberPanel().isVisible());
    }

    @Test
    public void can_hide_line_number(){     
        TextAreaView textAreaView = new TextAreaView();
        textAreaView.setShowLineNumber(false);
        assertTrue("Line number panel should be hidden",!textAreaView.getLineNumberPanel().isVisible());
    }

    @Test
    public void line_number_added_on_set_text(){
        TextAreaView textAreaView = new TextAreaView();
        textAreaView.setText("do not be a fuss.\n" +
                "this is just a line.\n" +
                "for the test case.");
        Component[] components = textAreaView.getLineNumberPanel().getComponents();
        assertTrue("Line number must be equal as number of lines in the text content",components.length == textAreaView.getLineCount());
    }
}
